RAIS  3.2
C:/Projekte/RAIS/UI Common/UserManagement.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031 
00032 using System.Web.UI;
00033 using System.Web.UI.WebControls;
00034 using System.Xml;
00035 
00036 using RAIS.ApplicationLogicLayer;
00037 using RAIS.Common.UserManagement;
00038 
00039 using DataRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.DataRole>;
00040 using DataRoleAttributes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.DataRoleAttribute>;
00041 using FunctionRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole>;
00042 using FunctionRoleAttributes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRoleAttribute>;
00043 using FunctionRoleCategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Category>;
00044 using FunctionRoleSubcategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Subcategory>;
00045 using Masks = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Mask>;
00046 using Regions = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Region>;
00047 using Districts = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.District>;
00048 using Facilities = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Facility>;
00049 using Practices = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Practice>;
00050 using UserTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.UserTypeData>;
00051 using Users = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.UserData>;
00052 using PageAccessRights = System.Collections.Generic.Dictionary<string, RAIS.UI.Common.UserManagement.AccessRight>;
00053 using ExpandedNodes = System.Collections.Generic.Dictionary<string, bool>;
00054 using MessageBoxRestrictions = System.Collections.Generic.List<RAIS.Common.UserManagement.MessageBoxRestriction>;
00055 
00056 namespace RAIS.UI.Common
00057 {
00061     public class UserManagement
00062     {
00063         const string score = "-";
00064         #region Public static methods
00065 
00066 
00067         public static Users GetLevelThreeUsers()
00068         {
00069             return RAIS.ApplicationLogicLayer.UserManagement.GetLevelThreeUsers();
00070         }
00071 
00072         //#-#
00073         public static bool createUserAssignmentForUser(UserAssignment ua, UserData ud, ref string outputMessage)
00074         {
00075             return RAIS.ApplicationLogicLayer.UserManagement.createUserAssignmentForUser(ua, ud, ref outputMessage);
00076         }
00077 
00078         //#-#
00079         public static bool editUserAssignment(UserAssignment ua, ref string outputMessage)
00080         {
00081             return RAIS.ApplicationLogicLayer.UserManagement.editUserAssignment(ua, ref outputMessage);
00082         }
00083 
00084         //#-#
00085         public static bool deleteUserAssignment(UserAssignment ua, ref string outputMessage)
00086         {
00087             return RAIS.ApplicationLogicLayer.UserManagement.deleteUserAssignment(ua, ref outputMessage);
00088         }
00089 
00095                 public static UserTypes UserTypes
00096                 {
00097                         get
00098                         {
00099                                 return RAIS.ApplicationLogicLayer.UserManagement.UserTypes;
00100                         }
00101                 }
00106         public static void ApplyAccessRights(Page page)
00107         {
00108             ControlCollection controls = page.Controls;
00109             ApplyAccessRightsToControls(controls);
00110             EnableCommonControls(page, true);
00111         }
00117         public static void EnableCommonControls(Page page, bool enable)
00118         {
00119             ControlCollection controls = page.Controls;
00120             EnableControls(controls, enable);
00121         }
00128         public static bool InitializeSiteMapTree(TreeView siteMap, XmlDocument siteMapDoc)
00129         {
00130             Page page = siteMap.Page;
00131 
00132             if (page.Session[UI.Common.Constants.PAGE_ACCESS_RIGHTS_TAG] == null)
00133                 page.Session[UI.Common.Constants.PAGE_ACCESS_RIGHTS_TAG] = new PageAccessRights();
00134 
00135             UserData currentUser = (UserData)page.Session[UI.Common.Constants.CURRENT_USER_TAG];
00136             string selectedCategory = (string)page.Session[UI.Common.Constants.SELECTED_CATEGORY_TAG];
00137 
00138             siteMap.Nodes.Clear();
00139 
00140             if (selectedCategory != null)
00141             {
00142                 if (siteMapDoc != null)
00143                 {
00144                     //XmlDocument siteMapDoc = RAIS.ApplicationLogicLayer.UserManagement.GetSiteMapByUser(currentUser);
00145                     //siteMapDoc.Save("c:\\sitemap_" + currentUser.Name + ".xml");
00146 
00147                     XmlElement siteMapRoot = siteMapDoc.DocumentElement;
00148                     InitializeSiteMapTreeNodes(siteMap.Nodes, siteMapRoot.ChildNodes, page, selectedCategory);
00149 
00150                     return true;
00151                 }
00152                 else
00153                     UI.Common.AccessManagement.SignOut(siteMap.Page);
00154             }
00155             return false;
00156         }
00160                 public static void InitializeAllMasksUserAccessRights(Page page)
00161                 {
00162                         page.Session[UI.Common.Constants.PAGE_ACCESS_RIGHTS_TAG] = new PageAccessRights();
00163 
00164                         TreeView siteMap = new TreeView();
00165                         UserData currentUser = (UserData)page.Session[UI.Common.Constants.CURRENT_USER_TAG];
00166                         XmlDocument siteMapDoc = RAIS.ApplicationLogicLayer.UserManagement.GetSiteMapByUser(currentUser, false);
00167                         XmlElement siteMapRoot = siteMapDoc.DocumentElement;
00168                         InitializeSiteMapTreeNodes(siteMap.Nodes, siteMapRoot.ChildNodes, page, null);
00169                 }
00176         public static void RestoreSiteMapExtensionState(TreeNodeCollection treeNodes, ExpandedNodes expandedNodes, string selectedNodePath)
00177         {
00178             if (expandedNodes != null)
00179             {
00180                 foreach (TreeNode node in treeNodes)
00181                 {
00182                     if (node.ValuePath != null && expandedNodes.ContainsKey(node.ValuePath))
00183                         node.Expand();
00184 
00185                     if (node.ChildNodes.Count == 0 && node.ValuePath != null && node.ValuePath == selectedNodePath)
00186                         node.Select();
00187 
00188                     RestoreSiteMapExtensionState(node.ChildNodes, expandedNodes, selectedNodePath);
00189                 }
00190             }
00191         }
00198         public static bool RestoreSelectedNode(TreeNodeCollection treeNodes, string selectedNodePath)
00199         {
00200             foreach (TreeNode node in treeNodes)
00201             {
00202                 if (node.ChildNodes.Count == 0 )
00203                 {
00204                     if (node.ValuePath != null && node.ValuePath == selectedNodePath)
00205                     {
00206                         node.Select();
00207                         return true;
00208                     }
00209                 }
00210                 else
00211                 {
00212                     if (RestoreSelectedNode(node.ChildNodes, selectedNodePath))
00213                         return true;
00214                 }
00215             }
00216             return false;
00217         }
00218 
00223         public static void ProcessTreeViewOnRedirect(TreeView siteMap)
00224         {
00225             SaveTreeViewExpansionState(siteMap);
00226 
00227             if (!String.IsNullOrEmpty(GetRedirectionUrl(siteMap.SelectedNode)))
00228             {
00229                                 siteMap.Page.Response.Redirect(GetRedirectionUrl(siteMap.SelectedNode));
00230             }
00231             else
00232             {
00233                 int nodeCount = 0;
00234                 foreach (TreeNode node in siteMap.Nodes)
00235                 {
00236                     if (!node.Equals(siteMap.SelectedNode))
00237                         nodeCount += node.ChildNodes.Count+1;
00238                     else
00239                     {
00240                         siteMap.SelectedNode.NavigateUrl =
00241                             string.Format("javascript:TreeView_ToggleNode(TreeView1_Data,{0},document.getElementById('TreeView1n{0}'),' ',document.getElementById('TreeView1n{0}Nodes'))", nodeCount);
00242                     }
00243                 }
00244                 if ((bool)siteMap.SelectedNode.Expanded)
00245                     siteMap.SelectedNode.Collapse();
00246                 else
00247                     siteMap.SelectedNode.Expand();
00248 
00249                 string selectedNodePath = (string)siteMap.Page.Session[UI.Common.Constants.SITE_MAP_SELECTED_NODE];
00250                 RAIS.UI.Common.UserManagement.RestoreSelectedNode(siteMap.Nodes, selectedNodePath);
00251             }
00252             //PageManagement.HideDisabledMenuItems(siteMap.Page);
00253         }
00258         public static void InitializeUserTypesList(DropDownList list)
00259         {
00260             UserTypes supportedUserTypes = RAIS.ApplicationLogicLayer.UserManagement.UserTypes;
00261 
00262             string[] userTypeNames = new string[supportedUserTypes.Count];
00263             supportedUserTypes.Keys.CopyTo(userTypeNames, 0);
00264 
00265             UI.Common.Controls.InitializeList(list.Items, userTypeNames);
00266         }
00271         public static void InitializeUsersList(DropDownList list)
00272         {
00273             Users users = RAIS.ApplicationLogicLayer.UserManagement.Users;
00274 
00275             string[] userNames = new string[users.Count];
00276             users.Keys.CopyTo(userNames, 0);
00277 
00278             UI.Common.Controls.InitializeList(list.Items, userNames);
00279         }
00284         public static void InitializeUsersListBox(ListBox list)
00285         {
00286             Users users = RAIS.ApplicationLogicLayer.UserManagement.Users;
00287 
00288             string[] userNames = new string[users.Count];
00289             users.Keys.CopyTo(userNames, 0);
00290 
00291             UI.Common.Controls.InitializeList(list.Items, userNames);
00292         }
00293 
00294         // #-#-#
00295         public static void InitializeCustomUsersListBox(ListBox list, List<UserData> users)
00296         {
00297             //Users users = RAIS.ApplicationLogicLayer.UserManagement.Users;
00298 
00299             string[] userNames = new string[users.Count];
00300             for(int i = 0; i < users.Count; i++)
00301             {
00302                 userNames[i] = users[i].Login;
00303             }
00304 
00305             UI.Common.Controls.InitializeList(list.Items, userNames);
00306         }
00307 
00308 
00314         public static void InitializeDataRoles(Page page)
00315         {
00316             DataRoles dataRoles = RAIS.ApplicationLogicLayer.UserManagement.DataRoles;
00317             page.Session[RAIS.UI.Common.Constants.DATA_ROLES_TAG] = dataRoles;
00318         }
00323                 public static void InitializeDataRolesListPlusEmptyRow(DropDownList list)
00324                 {
00325                         InitializeDataRolesList(list);
00326                         list.Items.Insert(0, new ListItem(string.Empty));
00327                 }
00332         public static void InitializeDataRolesList(DropDownList list)
00333         {
00334             if (list.Page.Session[RAIS.UI.Common.Constants.DATA_ROLES_TAG] == null)
00335             {
00336                 InitializeDataRoles(list.Page);
00337             }
00338 
00339             DataRoles dataRoles = (DataRoles)list.Page.Session[RAIS.UI.Common.Constants.DATA_ROLES_TAG];
00340 
00341             string[] dataRoleNames = new string[dataRoles.Keys.Count]; 
00342             dataRoles.Keys.CopyTo(dataRoleNames, 0);
00343 
00344             UI.Common.Controls.InitializeList(list.Items, dataRoleNames);
00345         }
00350         public static void InitializeDataRolesListBox(ListBox list)
00351         {
00352             if (list.Page.Session[RAIS.UI.Common.Constants.DATA_ROLES_TAG] == null)
00353             {
00354                 InitializeDataRoles(list.Page);
00355             }
00356 
00357             DataRoles dataRoles = (DataRoles)list.Page.Session[RAIS.UI.Common.Constants.DATA_ROLES_TAG];
00358 
00359             string[] dataRoleNames = new string[dataRoles.Keys.Count]; 
00360             dataRoles.Keys.CopyTo(dataRoleNames, 0);
00361 
00362             UI.Common.Controls.InitializeList(list.Items, dataRoleNames);
00363         }
00364 
00365 
00366         // #-#-#
00371                 public static void InitializeDataRolesListBox(ListBox list, string selection)
00372                 {
00373                         if (list.Page.Session[RAIS.UI.Common.Constants.DATA_ROLES_TAG] == null)
00374                         {
00375                                 InitializeDataRoles(list.Page);
00376                         }
00377 
00378                         DataRoles dataRoles = (DataRoles)list.Page.Session[RAIS.UI.Common.Constants.DATA_ROLES_TAG];
00379 
00380             List<string> keysTodelete = new List<string>();
00381             foreach (DataRole dr in dataRoles.Values)
00382             {
00383                 if (dr.Name.Contains("MBR_for_"))
00384                     keysTodelete.Add(dr.Name);
00385             }
00386             foreach (string del in keysTodelete)
00387             {
00388                 dataRoles.Remove(del);
00389             }
00390 
00391                         string[] dataRoleNames = new string[dataRoles.Keys.Count];
00392                         dataRoles.Keys.CopyTo(dataRoleNames, 0);
00393 
00394                         // Clear list before initializaton to have roles ordered
00395                         list.Items.Clear();
00396                         UI.Common.Controls.InitializeList(list.Items, dataRoleNames);
00397 
00398                         // Select current value
00399                         if (!string.IsNullOrEmpty(selection))
00400                         {
00401                                 ListItem listItem = list.Items.FindByText(selection);
00402                                 if (listItem != null)
00403                                         listItem.Selected = true;
00404                         }
00405                         else
00406                         {
00407                                 if (list.Items.Count != 0)
00408                                         list.SelectedIndex = 0;
00409                         }
00410                 }
00411 
00412 
00413 
00419         public static void InitializePracticesList(DropDownList list)
00420         {
00421             Practices practices = RAIS.ApplicationLogicLayer.UserManagement.Practices;
00422 
00423             string[] practiceNames = new string[practices.Count];
00424             practices.Keys.CopyTo(practiceNames, 0);
00425 
00426             UI.Common.Controls.InitializeList(list.Items, practiceNames);
00427         }
00428 
00433         public static void InitializePracticesListPlusEmptyRow(DropDownList list)
00434         {
00435             InitializePracticesList(list);
00436             list.Items.Insert(0, new ListItem(string.Empty));
00437         }
00438 
00443                 public static void InitializeFacilitiesListPlusEmptyRow(DropDownList list)
00444                 {
00445                         InitializeFacilitiesList(list);
00446                         list.Items.Insert(0, new ListItem(string.Empty));
00447                 }
00452         public static void InitializeFacilitiesList(DropDownList list)
00453         {
00454             Facilities facilities = RAIS.ApplicationLogicLayer.UserManagement.Facilities;
00455 
00456             string[] facilityNames = new string[facilities.Count];
00457             facilities.Keys.CopyTo(facilityNames, 0);
00458 
00459             UI.Common.Controls.InitializeList(list.Items, facilityNames);
00460         }
00465         public static void InitializeFacilitiesList(DropDownList list, string regionName, string districtName)
00466         {
00467             Regions regions = (Regions)list.Page.Session[RAIS.UI.Common.Constants.REGIONS_TAG];
00468             if (regions != null)
00469             {
00470                                 Region region = null;
00471                                 District district = null;
00472                                 if (string.IsNullOrEmpty(regionName))
00473                                 {
00474                                         region = new Region();
00475                                         district = new District();
00476                                 }
00477                                 else
00478                                 {
00479                                         region = regions[regionName];
00480                                         if (string.IsNullOrEmpty(districtName))
00481                                         {
00482                                                 district = new District();
00483                                         }
00484                                         else
00485                                         {
00486                                                 Districts districts = RAIS.ApplicationLogicLayer.UserManagement.GetDistrictsByRegion(region);
00487                                                 district = districts[districtName];
00488                                         }
00489                                 }
00490                 Facilities facilities = RAIS.ApplicationLogicLayer.UserManagement.GetFacilitiesByRegionAndDistrict(region, district);
00491 
00492                 string[] facilityNames = new string[facilities.Count];
00493                 facilities.Keys.CopyTo(facilityNames, 0);
00494 
00495                 UI.Common.Controls.InitializeList(list.Items, facilityNames);
00496             }
00497 
00498         }
00504                 public static void InitializeDistrictsListWithEmptyRow(DropDownList list, string regionName)
00505                 {
00506                         InitializeDistrictsList(list, regionName);
00507                         list.Items.Insert(0, new ListItem(string.Empty));
00508                 }
00514                 public static void InitializeDistrictsList(DropDownList list, string regionName)
00515         {
00516             Regions regions = (Regions)list.Page.Session[RAIS.UI.Common.Constants.REGIONS_TAG];
00517             if (regions != null)
00518             {
00519                                 if (regionName == string.Empty)
00520                                 {
00521                                         list.Items.Clear();
00522                                 }
00523                                 else
00524                                 {
00525                                         Region region = regions[regionName];
00526                                         Districts districts = RAIS.ApplicationLogicLayer.UserManagement.GetDistrictsByRegion(region);
00527                                         string[] districtNames = new string[districts.Count];
00528                                         districts.Keys.CopyTo(districtNames, 0);
00529 
00530                                         UI.Common.Controls.InitializeList(list.Items, districtNames);
00531                                 }
00532             }
00533         }
00538                 public static void InitializeRegionsListWithEmptyRow(DropDownList list, DataRole dataRole)
00539                 {
00540                         InitializeRegionsList(list, dataRole);
00541                         list.Items.Insert(0, new ListItem(string.Empty));
00542                 }
00547         public static void InitializeRegionsList(DropDownList list, DataRole dataRole)
00548         {
00549             Regions regions         = RAIS.ApplicationLogicLayer.UserManagement.Regions;
00550                         Regions filtredRegions = regions; // FilterRegionsList(regions, dataRole);
00551 
00552             list.Page.Session[RAIS.UI.Common.Constants.REGIONS_TAG] = filtredRegions;
00553 
00554             string[] regionNames = new string[filtredRegions.Count];
00555             filtredRegions.Keys.CopyTo(regionNames, 0);
00556 
00557             UI.Common.Controls.InitializeList(list.Items, regionNames);
00558         }
00563         public static void InitializeDataRoleAttributesList(ListBox list, DataRole dataRole)
00564         {
00565             if (dataRole != null)
00566             {
00567                 DataRoleAttributes attributes = dataRole.Attributes;
00568 
00569                 string[] attributeNames = new string[attributes.Count];
00570                 attributes.Keys.CopyTo(attributeNames, 0);
00571 
00572                 UI.Common.Controls.InitializeList(list.Items, attributeNames);
00573             }
00574         }
00581         public static void InitializeFuncitonRoleAttributesList(ListBox list, FunctionRole functionRole, string[] accessNames)
00582         {
00583             if (functionRole != null)
00584             {
00585                 FunctionRoleAttributes attributes = functionRole.Attributes;
00586 
00587                 string[] attributeNames = new string[attributes.Count];
00588                 attributes.Keys.CopyTo(attributeNames, 0);
00589 
00590                 UI.Common.Controls.InitializeList(list.Items, attributeNames);
00591 
00592                 int i=0;
00593                 foreach( FunctionRoleAttribute attribute in attributes.Values)
00594                 {
00595                     ListItem item = list.Items[i];
00596 
00597                     string toolTip = item.Text + " (";
00598 
00599 
00600                     if (attribute.AccessView && accessNames[0] != null)
00601                         toolTip += accessNames[0][0];
00602                     else
00603                         toolTip += score;
00604 
00605                     if (attribute.AccessAdd && accessNames[1] != null)
00606                         toolTip += accessNames[1][0];
00607                     else
00608                         toolTip += score;
00609 
00610                     if (attribute.AccessEdit && accessNames[2] != null)
00611                         toolTip += accessNames[2][0];
00612                     else
00613                         toolTip += score;
00614 
00615                     if (attribute.AccessDelete && accessNames[3] != null)
00616                         toolTip += accessNames[3][0];
00617                     else
00618                         toolTip += score;
00619 
00620                     toolTip += ")";
00621 
00622                     item.Attributes["title"] = toolTip;
00623 
00624                     i++;
00625                 }
00626 
00627             }
00628         }
00634         public static void InitializeFunctionalRoles(Page page)
00635         {
00636             FunctionRoles functionRoles = RAIS.ApplicationLogicLayer.UserManagement.FunctionalRoles;
00637             page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] = functionRoles;
00638         }
00644                 public static void InitializePredefinedFunctionalRoles(Page page)
00645                 {
00646                         FunctionRoles functionRoles = RAIS.ApplicationLogicLayer.UserManagement.PredefinedFunctionalRoles;
00647                         page.Session[RAIS.UI.Common.Constants.PREDEFINED_FUNCTION_ROLES_TAG] = functionRoles;
00648                 }
00653                 public static void InitializeFunctionalRolesListPlusEmptyRow(DropDownList list)
00654                 {
00655                         InitializeFunctionalRolesList(list);
00656                         list.Items.Insert(0, new ListItem(string.Empty));
00657                 }
00662         public static void InitializeFunctionalRolesList(DropDownList list)
00663         {
00664                         if (list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] == null)
00665                         {
00666                                 InitializeFunctionalRoles(list.Page);
00667                         }
00668 
00669                         FunctionRoles functionRoles = (FunctionRoles)list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG];
00670                         string[] functionRoleNames = new string[functionRoles.Keys.Count]; 
00671             functionRoles.Keys.CopyTo(functionRoleNames, 0);
00672 
00673             UI.Common.Controls.InitializeList(list.Items, functionRoleNames);
00674         }
00679                 public static void InitializePredefinedFunctionalRolesList(DropDownList list)
00680                 {
00681                         if (list.Page.Session[RAIS.UI.Common.Constants.PREDEFINED_FUNCTION_ROLES_TAG] == null)
00682                         {
00683                                 InitializePredefinedFunctionalRoles(list.Page);
00684                         }
00685 
00686                         FunctionRoles functionRoles = (FunctionRoles)list.Page.Session[RAIS.UI.Common.Constants.PREDEFINED_FUNCTION_ROLES_TAG];
00687                         string[] functionRoleNames = new string[functionRoles.Keys.Count];
00688                         functionRoles.Keys.CopyTo(functionRoleNames, 0);
00689 
00690                         UI.Common.Controls.InitializeList(list.Items, functionRoleNames);
00691                 }
00696         public static void InitializeFunctionalRolesListBox(ListBox list)
00697         {
00698             if (list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] == null)
00699             {
00700                 InitializeFunctionalRoles(list.Page);
00701             }
00702 
00703             FunctionRoles functionRoles = (FunctionRoles)list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG];
00704             string[] functionRoleNames = new string[functionRoles.Keys.Count];
00705             functionRoles.Keys.CopyTo(functionRoleNames, 0);
00706 
00707             UI.Common.Controls.InitializeList(list.Items, functionRoleNames);
00708         }
00713                 public static void InitializeFunctionalRolesListBox(ListBox list, string selection)
00714                 {
00715                         if (list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] == null)
00716                         {
00717                                 InitializeFunctionalRoles(list.Page);
00718                         }
00719 
00720                         FunctionRoles functionRoles = (FunctionRoles)list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG];
00721                         string[] functionRoleNames = new string[functionRoles.Keys.Count];
00722                         functionRoles.Keys.CopyTo(functionRoleNames, 0);
00723 
00724                         // Clear list before initializaton to have roles ordered
00725                         list.Items.Clear();
00726                         UI.Common.Controls.InitializeList(list.Items, functionRoleNames);
00727 
00728                         // Select current value
00729                         if (!string.IsNullOrEmpty(selection))
00730                         {
00731                                 ListItem listItem = list.Items.FindByText(selection);
00732                                 if (listItem != null)
00733                                         listItem.Selected = true;
00734                         }
00735                         else
00736                         {
00737                                 if (list.Items.Count != 0)
00738                                         list.SelectedIndex = 0;
00739                         }
00740                 }
00745                 public static void InitializeFunctionalRolesListByUserType(DropDownList list, UserTypeData userTypeData)
00746                 {
00747                         FunctionRoles functionRoles = RAIS.ApplicationLogicLayer.UserManagement.GetFunctionalRolesByUserType(userTypeData);
00748 
00749             if (functionRoles.Count != 0)
00750             {
00751                 list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] = functionRoles;
00752                 string[] functionRoleNames = new string[functionRoles.Keys.Count];
00753                 functionRoles.Keys.CopyTo(functionRoleNames, 0);
00754 
00755                 UI.Common.Controls.InitializeList(list.Items, functionRoleNames);
00756             }
00757             else
00758                 InitializeFunctionalRolesList(list);
00759 
00760                 }
00765         public static void InitializeValidationList(DropDownList list)
00766         {
00767             Dictionary<FunctionRole.ValidationType, FunctionRole.ValidationTypeData> validationTypes = FunctionRole.ValidationTypesDictionary;
00768             string[] validationTypeNames = new string[validationTypes.Keys.Count];
00769 
00770             FunctionRole.ValidationTypeNamesDictionary.Keys.CopyTo(validationTypeNames, 0);
00771             UI.Common.Controls.InitializeList(list.Items, validationTypeNames);
00772         }
00777         public static void InitializeUserTypeList(DropDownList list)
00778         {
00779             UserTypes userTypes = UI.Common.UserManagement.UserTypes;
00780             string[] userTypeNames = new string[userTypes.Keys.Count];
00781             userTypes.Keys.CopyTo(userTypeNames, 0);
00782 
00783             UI.Common.Controls.InitializeList(list.Items, userTypeNames);
00784         }
00785 
00790         public static void InitializeCategoriesList(DropDownList list, FunctionRole role)
00791         {
00792             FunctionRoleCategories functionRolesCategories = RAIS.ApplicationLogicLayer.UserManagement.FunctionalRoleCategories;
00793             FunctionRoleCategories filtredCategories = functionRolesCategories;//FilterCategories(functionRolesCategories, role);
00794 
00795             list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_CATEGORIES_TAG] = filtredCategories;
00796 
00797             string[] functionRoleCategoriesNames = new string[filtredCategories.Keys.Count];
00798             filtredCategories.Keys.CopyTo(functionRoleCategoriesNames, 0);
00799 
00800             UI.Common.Controls.InitializeList(list.Items, functionRoleCategoriesNames);
00801         }
00806         public static void InitializeSubcategoriesList( DropDownList list, 
00807                                                         FunctionRole.Category category, 
00808                                                         FunctionRole role)
00809         {
00810             FunctionRoleSubcategories functionRolesSubcategories = ApplicationLogicLayer.UserManagement.GetFunctionalRoleSubcategories(category);
00811             FunctionRoleSubcategories filtredSubcategories = FilterSubcategories(functionRolesSubcategories, category, role);
00812             list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_SUBCATEGORIES_TAG] = filtredSubcategories;
00813 
00814             string[] functionRoleSubcategoriesNames = new string[filtredSubcategories.Keys.Count];
00815             filtredSubcategories.Keys.CopyTo(functionRoleSubcategoriesNames, 0);
00816 
00817             UI.Common.Controls.InitializeList(list.Items, functionRoleSubcategoriesNames);
00818         }
00823         public static void InitializeMasksList( DropDownList list, 
00824                                                 FunctionRole.Category category, 
00825                                                 FunctionRole.Subcategory subcategory, 
00826                                                 FunctionRole role)
00827         {
00828             Masks masks = ApplicationLogicLayer.UserManagement.GetMasks(category, subcategory);
00829             Masks filtredMasks = FilterMasks(masks, subcategory, category, role);
00830             list.Page.Session[RAIS.UI.Common.Constants.MASKS_TAG] = filtredMasks;
00831 
00832             string[] maskNames = new string[filtredMasks.Keys.Count];
00833             filtredMasks.Keys.CopyTo(maskNames, 0);
00834 
00835             UI.Common.Controls.InitializeList(list.Items, maskNames);
00836         }
00837 
00842                 public static Facility GetFacilityByID(int facilityID)
00843                 { 
00844                         return RAIS.ApplicationLogicLayer.UserManagement.GetFacilityByID(facilityID);
00845                 }
00846 
00847                 public static Dictionary<string, string> GetUserStatusesHistoryByUser(Page page, UserData user, bool reset)
00848                 {
00849                         string tagName = RAIS.UI.Common.Constants.USER_STATUSES_TAG;
00850                         Dictionary<string, string> userStatuses = new Dictionary<string, string>();
00851 
00852                         if (reset)
00853                                 page.Session[tagName] = null;
00854 
00855                         if (page.Session[tagName] == null)
00856                         {
00857                                 userStatuses = RAIS.ApplicationLogicLayer.UserManagement.GetUserStatusesHistoryByUser(user);
00858                                 page.Session[tagName] = userStatuses;
00859                         }
00860                         else
00861                         {
00862                                 userStatuses = (Dictionary<string, string>)page.Session[tagName];
00863                         }
00864 
00865                         return userStatuses;
00866                 }
00871                 public static void InitializeUserStatusesListBox(ListBox list, UserData user)
00872                 {
00873                         Dictionary<string, string> userStatuses = GetUserStatusesHistoryByUser(list.Page, user, true);
00874 
00875                         string[] userStatusDates = new string[userStatuses.Keys.Count];
00876                         userStatuses.Keys.CopyTo(userStatusDates, 0);
00877 
00878                         UI.Common.Controls.InitializeList(list.Items, userStatusDates);
00879                 }
00884                 public static Department GetDepartmentByID(int departmentID)
00885                 {
00886                         return RAIS.ApplicationLogicLayer.UserManagement.GetDepartmentByID(departmentID);
00887                 }
00888                 #endregion
00889         #region Private static helper methods
00890 
00894         public static void ApplyAccessRightsToControls(ControlCollection controls)
00895         {
00896             foreach (Control control in controls)
00897             {
00898                 ApplyViewRightToControl(control);
00899                 ApplyEditRightToControl(control);
00900                 ApplyAccessRightsToControls(control.Controls);
00901             }
00902         }
00907         public static void ApplyViewRightToControl(Control control)
00908         {
00909             if (!AccessRight.ControlView(control))
00910                 control.Visible = false;
00911         }
00916         public static void ApplyEditRightToControl(Control control)
00917         {
00918             if (!AccessRight.ControlEdit(control))
00919             {
00920                 if (control is TextBox)
00921                 {
00922                     TextBox textbox = (TextBox)control;
00923                     textbox.Enabled = false;
00924                 }
00925                 else
00926                 if (control is Button)
00927                 {
00928                     Button button = (Button)control;
00929                     button.Enabled = false;
00930                 }
00931                 else
00932                 if (control is RadioButton)
00933                 {
00934                     RadioButton button = (RadioButton)control;
00935                     button.Enabled = false;
00936                 }
00937                 else
00938                 if (control is CheckBox)
00939                 {
00940                     CheckBox button = (CheckBox)control;
00941                     button.Enabled = false;
00942                 }
00943                 else
00944                 if (control is RadioButtonList)
00945                 {
00946                     RadioButtonList list = (RadioButtonList)control;
00947                     list.Enabled = false;
00948                 }
00949                 else
00950                 if (control is DropDownList)
00951                 {
00952                     DropDownList list = (DropDownList)control;
00953                     list.Enabled = false;
00954                 }
00955             }
00956         }
00961         public static bool AccessToCategoryAllowed(string categoryName, Page page)
00962         {
00963             UserData currentUser = (UserData)page.Session[UI.Common.Constants.CURRENT_USER_TAG];
00964             if (currentUser != null)
00965                 return currentUser.HasAccessToCategory(categoryName);
00966             else
00967                 return false;
00968         }
00973         private static void SaveTreeViewExpansionState(TreeView siteMap)
00974         {
00975             ExpandedNodes expandedNodes = new Dictionary<string, bool>();//(ExpandedNodes)siteMap.Page.Session[UI.Common.Constants.SITE_MAP_EXPANSION_STATES];
00976             if( expandedNodes == null )
00977                 expandedNodes = new ExpandedNodes();
00978 
00979             TreeNodeCollection nodes = siteMap.Nodes;
00980             string selectedNodePath = (string)siteMap.Page.Session[UI.Common.Constants.SITE_MAP_SELECTED_NODE];
00981 
00982             RetrieveNodesExpansionState(nodes, expandedNodes, ref selectedNodePath);
00983 
00984             siteMap.Page.Session[UI.Common.Constants.SITE_MAP_EXPANSION_STATES] = expandedNodes;
00985             siteMap.Page.Session[UI.Common.Constants.SITE_MAP_SELECTED_NODE] = selectedNodePath;
00986         }
00994         private static void RetrieveNodesExpansionState(TreeNodeCollection nodes, ExpandedNodes expandedNodes, ref string selectedNodePath)
00995         {
00996             foreach (TreeNode node in nodes)
00997             {
00998                 if (node.Expanded != null && node.Expanded == true && node.ChildNodes.Count > 0)
00999                 {
01000                     if (!expandedNodes.ContainsKey(node.ValuePath))
01001                         expandedNodes.Add(node.ValuePath, true);
01002                     RetrieveNodesExpansionState(node.ChildNodes, expandedNodes, ref selectedNodePath);
01003                 }
01004                 else
01005                 {
01006                     if (expandedNodes.ContainsKey(node.ValuePath))
01007                         expandedNodes.Remove(node.ValuePath);
01008                 }
01009 
01010                 if (node.Selected)
01011                 {
01012                     if (node.ChildNodes.Count == 0)
01013                         selectedNodePath = node.ValuePath;
01014                 }
01015             }
01016         }
01023         private static void InitializeSiteMapTreeNodes(TreeNodeCollection treeNodes, XmlNodeList documentNodes, Page page, string selectedCategory)
01024         {
01025             PageAccessRights pageAccessRights = (PageAccessRights)page.Session[UI.Common.Constants.PAGE_ACCESS_RIGHTS_TAG];
01026             Dictionary<string, string> renamedNodes = PageManagement.GetRenamedNodes(page);
01027             bool showProtectors = PageManagement.GetShowProtectors(page);
01028             bool showEvaluators = PageManagement.GetShowEvaluators(page);
01029 
01030             foreach (XmlNode documentNode in documentNodes)
01031             {
01032                 XmlAttributeCollection attributes = documentNode.Attributes;
01033                 XmlNode nodeName = attributes.GetNamedItem("Name");
01034 
01035                 if (nodeName == null || (selectedCategory != null && selectedCategory != nodeName.Value))
01036                     continue;
01037 
01038                 TreeNode node = new TreeNode(nodeName.Value);
01039                 XmlNode nodeReference = attributes.GetNamedItem("Reference");
01040 
01041                 if (nodeReference != null)
01042                 {
01043                     XmlNode nodeAccess = attributes.GetNamedItem("AccessRights");
01044                     if (nodeAccess != null && nodeAccess.Value != null)
01045                     {
01046                         SetRedirectionUrl(node, nodeReference.Value);
01047                         pageAccessRights[nodeReference.Value] = new AccessRight(nodeAccess.Value);
01048                     }
01049                 }
01050                 else                
01051                     node.Collapse();
01052                 
01053 
01054                 if (selectedCategory != null) 
01055                     InitializeSiteMapTreeNodes(treeNodes, documentNode.ChildNodes, page, null);
01056                 else
01057                 {
01058                     InitializeSiteMapTreeNodes(node.ChildNodes, documentNode.ChildNodes, page, null);
01059                     
01060                     if (node.ChildNodes.Count > 0 || (!String.IsNullOrEmpty(GetRedirectionUrl(node)) && pageAccessRights[GetRedirectionUrl(node)].View))
01061                     {
01062                         if (renamedNodes.ContainsKey(node.Value))
01063                             node.Text = renamedNodes[node.Value];
01064 
01065                         if (node.Text.StartsWith(RAIS.Common.Constants.PROTECTOR_PREFIX) && !showProtectors
01066                             || node.Text.StartsWith(RAIS.Common.Constants.EVALUATOR_PREFIX) && !showEvaluators)
01067                             continue;
01068 
01069                         if (node.Text == "Show system fields")
01070                             node.Text = "Show system fields checkbox";
01071                         
01072                         treeNodes.Add(node);
01073                     }
01074                 }
01075             }
01076         }
01082         private static void SetRedirectionUrl(TreeNode treeNode, string redirectionUrl)
01083         {
01084             if (treeNode.Value != null)
01085             {
01086                 treeNode.Value = UI.Common.Constants.REDIRECTION_URL_PREFIX + redirectionUrl;
01087             }
01088         }
01094         private static string GetRedirectionUrl(TreeNode treeNode)
01095         {
01096             if (treeNode.Value != null)
01097             {
01098                 int indexOfPrefix = treeNode.Value.LastIndexOf(UI.Common.Constants.REDIRECTION_URL_PREFIX);
01099                 if (indexOfPrefix >= 0)
01100                 {
01101                     int indexOfUrl = indexOfPrefix + UI.Common.Constants.REDIRECTION_URL_PREFIX.Length;
01102                     string url = treeNode.Value.Substring(indexOfUrl);
01103                     return url;
01104                 }
01105                 else
01106                     return null;
01107             }
01108             else
01109                 return null;
01110         }
01119         private static Regions FilterRegionsList(Regions regions, DataRole role)
01120         {
01121             if (role != null && role.ContainsRegionRestriction(RAIS.Common.Constants.ALL_REGIONS))
01122             {
01123                 Regions fitredRegions = new Regions();
01124                 fitredRegions[RAIS.Common.Constants.ALL_REGIONS] = regions[RAIS.Common.Constants.ALL_REGIONS];
01125                 return fitredRegions;
01126             }
01127             else
01128                 return regions;
01129         }
01138         private static FunctionRoleCategories FilterCategories(FunctionRoleCategories categories, FunctionRole role)
01139         {
01140             if (role != null && role.ContainsCategoryRestriction(RAIS.Common.Constants.ALL_CATEGORIES))
01141             {
01142                 FunctionRoleCategories fitredCategories = new FunctionRoleCategories();
01143                 fitredCategories[RAIS.Common.Constants.ALL_CATEGORIES] = categories[RAIS.Common.Constants.ALL_CATEGORIES];
01144                 return fitredCategories;
01145             }
01146             else
01147                 return categories;
01148         }
01158         private static FunctionRoleSubcategories FilterSubcategories(  FunctionRoleSubcategories subcategories,
01159                                                                        FunctionRole.Category     category,
01160                                                                        FunctionRole              role)
01161         {
01162             if ((role != null && role.ContainsSubcategoryRestriction(category, RAIS.Common.Constants.ALL_SUBCATEGORIES)) ||
01163                   (category != null && category.Name == RAIS.Common.Constants.ALL_CATEGORIES))
01164             {
01165                 FunctionRoleSubcategories fitredSubcategories = new FunctionRoleSubcategories();
01166                 fitredSubcategories[RAIS.Common.Constants.ALL_SUBCATEGORIES] = subcategories[RAIS.Common.Constants.ALL_SUBCATEGORIES];
01167                 return fitredSubcategories;
01168             }
01169             else
01170                 return subcategories;
01171         }
01183         private static Masks FilterMasks(  Masks masks,
01184                                            FunctionRole.Subcategory subcategory,
01185                                            FunctionRole.Category    category,
01186                                            FunctionRole             role)
01187         {
01188             if ((role != null && role.ContainsMaskRestriction(category, subcategory, RAIS.Common.Constants.ALL_MASKS)) ||
01189                     (subcategory != null && subcategory.Name == RAIS.Common.Constants.ALL_SUBCATEGORIES) ||
01190                     (category != null && category.Name == RAIS.Common.Constants.ALL_CATEGORIES))
01191             {
01192                 Masks fitredMasks = new Masks();
01193                 fitredMasks[RAIS.Common.Constants.ALL_MASKS] = masks[RAIS.Common.Constants.ALL_MASKS];
01194                 return fitredMasks;
01195             }
01196             else
01197                 return masks;
01198         }
01204         private static void EnableControls(ControlCollection controls, bool enable)
01205         {
01206             foreach (Control control in controls)
01207             {
01208                 switch (control.ClientID)
01209                 {
01210                     case "LBLadmin": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_ADMINISTRATION, control.Page)); break;
01211                     case "LBLinput": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_INPUT, control.Page)); break;
01212                     case "LBLregsys": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_REGULATORY_SYSTEM, control.Page)); break;
01213                     case "LBLstats": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_STATISTICS, control.Page)); break;
01214                     case "LBLquery": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_QUERY, control.Page)); break;
01215                     case "LBLtools": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_TOOLS, control.Page)); break;
01216 
01217                     case "LBLhelp": EnableMenuItems(control, true, true); break;
01218                     case "LBLmessage":
01219                     case "LBLlogout": EnableMenuItems(control, enable, true); break;
01220 
01221                     case "LBTNadmin": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_ADMINISTRATION, control.Page)); break;
01222                     case "LBTNinput": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_INPUT, control.Page)); break;
01223                     case "LBTNregsys": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_REGULATORY_SYSTEM, control.Page)); break;
01224                     case "LBTNquery": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_QUERY, control.Page)); break;
01225                     case "LBTNstatistics": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_STATISTICS, control.Page)); break;
01226                     case "LBTNtools": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_TOOLS, control.Page)); break;
01227 
01228                     case "LBTNdefault": EnableMenuItems(control, true, true); break;
01229                     case "LBTNmessagebox": EnableMenuItems(control, enable, AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_MESSAGEBOX, control.Page)); break;
01230                     case "LBTNlogout": EnableMenuItems(control, enable, true); break;
01231                     case "TreeView1": EnableControl(control, enable); break;
01232 
01233                     default: break;
01234                 }
01235                 EnableControls(control.Controls, enable);
01236             }
01237         }
01238 
01239         private static void EnableMenuItems(Control control, bool enable, bool allowed)
01240         {
01241             if (control is Label)
01242             {
01243                 Label lable = (Label)control;
01244                 lable.Enabled = enable;
01245                 lable.Visible = allowed;
01246             }
01247             else
01248                 if (control is System.Web.UI.HtmlControls.HtmlAnchor)
01249                 {
01250                     System.Web.UI.HtmlControls.HtmlAnchor lable = (System.Web.UI.HtmlControls.HtmlAnchor)control;
01251                     lable.Disabled = !enable;
01252                     lable.Visible = allowed;
01253                 }
01254         }
01255 
01256 
01262         private static void EnableControl(Control control, bool enable)
01263         {
01264             if (control is Label)
01265             {
01266                 Label lable = (Label)control;
01267                 lable.Enabled = enable;
01268             }
01269             else
01270             if (control is System.Web.UI.HtmlControls.HtmlAnchor)
01271             {
01272                 System.Web.UI.HtmlControls.HtmlAnchor lable = (System.Web.UI.HtmlControls.HtmlAnchor)control;
01273                 lable.Disabled = !enable;
01274             }
01275             else
01276             if (control is TreeView)
01277             {
01278                 TreeView tree = (TreeView)control;
01279                 tree.Enabled = enable;
01280             }
01281     }
01282         #endregion
01283         #region Nested classes
01284 
01287         public class AccessRight
01288         {
01289             #region Fields
01290             string accessFlags = "";
01291             #endregion
01292             #region AccessFilters
01293             static string ViewAccess = "V";
01294             static string EditAccess = "E";
01295             static string AddAccess = "A";
01296             static string DeleteAccess = "D";
01297             #endregion
01298             #region Constructor
01299             public AccessRight(string accessFlags)
01300             {
01301                 this.accessFlags = accessFlags;
01302             }
01303             #endregion
01304             #region Properties
01305             public bool View
01306             {
01307                 get
01308                 {
01309                     return this.accessFlags.Contains(ViewAccess);
01310                 }
01311             }
01312             public bool Edit
01313             {
01314                 get
01315                 {
01316                     return this.accessFlags.Contains(EditAccess);
01317                 }
01318             }
01319             public bool Add
01320             {
01321                 get
01322                 {
01323                     return this.accessFlags.Contains(AddAccess);
01324                 }
01325             }
01326             public bool Delete
01327             {
01328                 get
01329                 {
01330                     return this.accessFlags.Contains(DeleteAccess);
01331                 }
01332             }
01333             public bool Any { get { return View || Edit || Add || Delete; } }
01334             #endregion
01335             #region Public static methods
01336             static public bool ControlView(Control control)
01337             {
01338                 Page page = control.Page;
01339 
01340                 if (page.AppRelativeVirtualPath == "~/Default.aspx" || page.AppRelativeVirtualPath == "~/ChangePassword.aspx")
01341                                         return true;
01342                                 else if (page.AppRelativeVirtualPath == "~/Admin.aspx")
01343                                         return AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_ADMINISTRATION, control.Page);
01344                                 else if (page.AppRelativeVirtualPath == "~/RegSys.aspx")
01345                                         return AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_REGULATORY_SYSTEM, control.Page);
01346                                 else if (page.AppRelativeVirtualPath == "~/Input.aspx")
01347                                         return AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_INPUT, control.Page);
01348                                 else if (page.AppRelativeVirtualPath == "~/Query.aspx")
01349                                         return AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_QUERY, control.Page);
01350                                 else if (page.AppRelativeVirtualPath == "~/Statistics.aspx")
01351                                         return AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_STATISTICS, control.Page);
01352                 else if (page.AppRelativeVirtualPath == "~/MessageBox.aspx")
01353                     return AccessToCategoryAllowed(RAIS.Common.Constants.CATEGORY_NAME_MESSAGEBOX, control.Page);
01354 
01355                 PageAccessRights pageAccessRights = (PageAccessRights)page.Session[UI.Common.Constants.PAGE_ACCESS_RIGHTS_TAG];
01356                 if (pageAccessRights != null && pageAccessRights.Count != 0)
01357                 {
01358                     //string key = page.AppRelativeVirtualPath;
01359                     //key = key.Substring(key.LastIndexOf('/') + 1);
01360                                         string key = page.AppRelativeVirtualPath
01361                                                 + ((page.ClientQueryString == string.Empty)
01362                                                         ? string.Empty
01363                                                         : "?" + page.ClientQueryString);
01364                                         if (pageAccessRights.ContainsKey(key))
01365                     {
01366                         AccessRight accessRight = pageAccessRights[key];
01367                         if (accessRight != null)
01368                             return accessRight.View;
01369                     }
01370                     else
01371                                                 return true;
01372                 }
01373                 return false;
01374             }
01375             static public bool ControlEdit(Control control)
01376             {
01377                 Page page = control.Page;
01378                 PageAccessRights pageAccessRights = (PageAccessRights)page.Session[UI.Common.Constants.PAGE_ACCESS_RIGHTS_TAG];
01379                 if (pageAccessRights != null)
01380                 {
01381                     string key = page.AppRelativeVirtualPath;
01382                     key = key.Substring(key.LastIndexOf('/') + 1);
01383                     if (pageAccessRights.ContainsKey(key))
01384                     {
01385                         AccessRight accessRight = pageAccessRights[key];
01386                         if (accessRight != null)
01387                             return accessRight.Edit;
01388                     }
01389                     else if(pageAccessRights.ContainsKey(page.AppRelativeVirtualPath))
01390                     {
01391                         AccessRight accessRight = pageAccessRights[page.AppRelativeVirtualPath];
01392                         if (accessRight != null)
01393                             return accessRight.Edit;
01394                     }
01395                     else
01396                         return true;
01397                 }
01398                 return false;
01399             }
01400             #endregion
01401         }
01402         #endregion
01403 
01404         //#-#
01405         public static MessageBoxRestrictions getActiveMessageBoxRestrictionsForUser(UserData user)
01406         {
01407             return RAIS.ApplicationLogicLayer.UserManagement.getActiveMessageBoxRestrictionsForUser(user);
01408         }
01409         public static MessageBoxRestrictions getActiveMessageBoxRestrictionsForUser(UserData user, DateTime selectedDate)
01410         {
01411             return RAIS.ApplicationLogicLayer.UserManagement.getActiveMessageBoxRestrictionsForUser(user, selectedDate);
01412         }
01413 
01414         /* #+#
01415          *
01416          */
01417         public static DataRole getMessageBoxDataRoleByUser(UserData user)
01418         {
01419             return RAIS.ApplicationLogicLayer.UserManagement.getMessageBoxDataRoleByUser(user);
01420         }
01421         /* */
01422 
01423         public static DataRole getMessageBoxDataRoleByUserAndDate(UserData user, DateTime date)
01424         {
01425             return RAIS.ApplicationLogicLayer.UserManagement.getMessageBoxDataRoleByUserAndDate(user, date);
01426         }
01427 
01428 
01429         public static List<UserData> GetUserFreeToTakeOver()
01430         {
01431             return RAIS.ApplicationLogicLayer.UserManagement.GetUserFreeToTakeOver();
01432         }
01433 
01434         public static bool clearTakeOverForUser(UserData user)
01435         {
01436             return RAIS.ApplicationLogicLayer.UserManagement.clearTakeOverForUser(user);
01437         }
01438         /*public static bool saveMessageboxRestriction(UserData user, DataRole dataRole, ref string returnMessage)
01439         {
01440             return RAIS.ApplicationLogicLayer.UserManagement.saveMessageboxRestriction(user, dataRole, ref returnMessage);
01441         }/* */
01442 
01443         public static List<MessageBoxRestriction> MessageboxRestrictionHistoryForUser(UserData user, ref string returnMessage)
01444         {
01445             return RAIS.ApplicationLogicLayer.UserManagement.MessageboxRestrictionHistoryForUser(user, ref returnMessage);
01446         }
01447 
01448     }
01449 }